//
//  BaseNavigationBarViewController.swift
//  ltsp
//
//  Created by jyvyi_ios on 2022/5/12.
//

import UIKit

#if canImport(SnapKit)
import SnapKit

class BaseNavigationBarViewController: BaseViewController {
    
    /// 自定义navigationBar高度
    var customNavigationBarHeight : CGFloat {
        get{
            return 0
        }
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        self.view.bringSubviewToFront(self.navigationBar)
    }
    
    @available(iOS 11.0, *)
    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        
        self.navigationBar.snp.updateConstraints { make in
            make.height.equalTo(self.customNavigationBarHeight + self.view.safeAreaInsets.top)
        }
    }
    
    lazy var navigationBar: UIView = {
        
        let navigationBar = UIView()
        
        self.view.addSubview(navigationBar)
        navigationBar.snp.makeConstraints { make in
            make.left.right.top.equalToSuperview()
            make.height.equalTo(self.customNavigationBarHeight)
        }
        return navigationBar
    }()
}

#endif
